<template>
  <view v-if="pageShow" class="container">
    <!-- 需求状态、发布时间、擅长服务、所在地筛选 -->
    <view class="chose-area solid-bottom">
      <view class="chose-type">
        <picker
          :range="sortData"
          @change="changeSort"
          :value="sortValue"
          range-key="name"
        >
          <view class="chose-item">
            <text v-if="sortKey" class="title">{{
              sortData[sortKey].name
            }}</text>
            <text v-else class="title">需求状态</text>
            <text class="icon"></text>
          </view>
        </picker>
        <picker
          :range="dateData"
          @change="changeDate"
          :value="dateValue"
          range-key="name"
        >
          <view class="chose-item">
            <text v-if="dateKey" class="title">{{
              dateData[dateKey].name
            }}</text>
            <text v-else class="title">发布时间</text>
            <text class="icon"></text>
          </view>
        </picker>
        <!-- <view class="chose-item" @click="showCategory">
          <text v-if="cateThirdName" class="title">{{ cateThirdName }}</text>
          <text v-else class="title">擅长服务</text>
          <text class="icon"></text>
        </view> -->
        <!-- <chose-region @change1="regionName" @changes1="regionValue">
					<view class="chose-item">
						<text v-if="choseRegion.length > 0" class="title">{{ choseRegion[1].name }}</text>
						<text v-else class="title">所在地</text>
						<text class="icon"></text>
					</view>
				</chose-region> -->
				<chose-cate @change1="cateName" @cancels1="cancels" :cateList="categoryList">
          <view class="chose-item">
            <view class="title">{{ cateThirdName }}</view>
            <text class="icon"></text>
          </view>
        </chose-cate>
        <view @click="showCityListFn">
          <chose-region
            :disabled="true"
            @change1="regionName"
            @changes1="regionValue"
          >
            <view class="chose-item">
              <text v-if="choseRegion1" class="title">{{
                choseRegion1.name
              }}</text>
              <text v-else class="title">所在地</text>
              <text class="icon"></text>
            </view> </chose-region
        ></view>
      </view>
    </view>

    <!-- 需求列表 -->
    <scroll-view
      scroll-y="true"
      style="height: calc(100vh - 72rpx)"
      :refresher-threshold="50"
      :refresher-background="'#F7F7F7'"
      :refresher-enabled="true"
      :refresher-triggered="isRefreshing"
      @refresherrefresh="refresherrefresh"
      @scrolltolower="loadMore"
    >
      <view class="demand-list">
        <view
          class="list"
          v-for="(item, index) in demandList"
          :key="index"
          @click="goDetail(item)"
        >
          <view class="header">
            <view class="title">
              <text class="title-icon"></text>
              <text class="name">{{ item.name }}</text>
            </view>
            <view class="price">
              <text>{{ item.money == 0 ? "面议" : "¥" + item.money }}</text>
            </view>
          </view>
          <view class="main-content">
            <text>描述：{{ item.describe }}</text>
          </view>
          <view class="bottom">
            <view class="local">
              <text>{{ item.city_name }}</text>
              <text v-if="item.join_number > 0" style="margin-left: 14rpx"
                >{{ item.join_number }}人投标</text
              >
            </view>
            <view class="join-type">
              <text>{{
                item.status == 0
                  ? "可参与"
                  : item.status == 1
                  ? "已中标"
                  : item.status == 2
                  ? "已取消"
                  : ""
              }}</text>
            </view>
          </view>
        </view>
        <uni-load-more
          v-if="demandList.length > 0"
          :status="listStatus"
        ></uni-load-more>
        <view v-if="demandList.length === 0" class="empty-wrap">
          <image
            class="empty-img"
            src="https://xzcs-public-files.oss-cn-beijing.aliyuncs.com/static/coupon/contentVanshi.png"
          ></image>
          <text class="tips">暂无内容</text>
        </view>
      </view>
    </scroll-view>
    <!-- 服务类目 -->
    <view>
      <u-popup
        :show="categoryShow"
        closeable
        mode="bottom"
        @close="categoryShow = false"
        :closeOnClickOverlay="true"
      >
        <view class="cate-title">
          <view class="title solid-bottom">
            <view class="all-cate" @click="choseAll">全部</view>
            <view class="title-chose">擅长服务</view>
          </view>
          <view class="VerticalBox">
            <scroll-view class="VerticalNav" :scroll-y="true">
              <view
                class="cu-item"
                :class="index == tabCur ? 'first-cate cur' : ''"
                v-for="(item, index) in categoryList"
                :key="index"
                @tap="tabSelect(item, index)"
              >
                {{ item.name }}
              </view>
            </scroll-view>
            <scroll-view class="vertical-main" :scroll-y="true">
              <view class="right-main">
                <view
                  class="main-item"
                  v-for="(item, index) in cateSecondList"
                  :key="index"
                >
                  <view class="item-title">
                    {{ item.name }}
                  </view>
                  <view class="item-content">
                    <view
                      class="item-val"
                      v-for="(val, idx) in item.third"
                      :key="idx"
                      @click="thirdClick(val)"
                    >
                      {{ val.name }}
                    </view>
                  </view>
                </view>
              </view>
            </scroll-view>
          </view>
        </view>
      </u-popup>
    </view>
    <view class="bottom-btn">
      <image
        src="https://xzcs-public-files.oss-cn-beijing.aliyuncs.com/static/enterprise-service/demand/free-post-demand.png"
        class="img"
        @click="goPostDemand"
      ></image>
    </view>

    <!-- 所在地 -->
    <u-popup :show="showCityList" @close="closeCityList">
      <view class="city_list" style="height: 80vh; padding: 30rpx 0">
        <wfAddress @getCityInfo="getCityInfo"></wfAddress>
      </view>
    </u-popup>
  </view>
</template>

<script
  type="text/javascript"
  src="plus-confusion://../enterpriseServer/demandHall/index"
></script>

<style lang="scss" scoped>
@import "index.scss";
</style>
